import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';

// 静态路由
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/login.vue'),
    meta: { showBar: true, hideBg: true },
  },
  {
    path: '/',
    name: '/',
    component: () => import('@/views/index/index.vue'),
  },
  {
    path: '/list',
    name: 'list',
    component: () => import('@/views/list/list.vue'),
    meta: { showBar: true },
  },
  {
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import('@/views/error/404.vue'),
    meta: { showBar: true, title: '404' },
  },
];

/**
 * 创建路由
 */
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  // 刷新时，滚动条位置还原
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

export default router;
